home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / music / 7 / pascal / time.doc < prev    next >
Encoding:
Text File  |  1985-11-19  |  3.0 KB  |  102 lines

  1.  
  2.  
  3.  
  4. Time and Date                                                           Page 1
  5.  
  6.                            Time and Date Functions
  7.  
  8. If  you are writing an application which needs to find out the current time or
  9. date, you can call certain system routines to find out those values  (provided
  10. the user has set them using the control panel!).  The first routine allows you
  11. to retrieve the current date:
  12.  
  13. Get date.
  14.  
  15. FUNCTION t_getdate : Integer ;
  16.   GEMDOS( $2a ) ;
  17.  
  18. Use this call to retrieve the system date, in the following format:
  19.  
  20.  bits  contents
  21. -----  --------
  22.  0- 4  the day of the month (1-31)
  23.  5- 8  the month of the year (1-12)
  24.  9-15  the number of years since 1980 (0-119)
  25.  
  26. For example, the date February 5, 1986 would be:
  27.  
  28. $0C45 = 6*512 + 2*32 + 5
  29. (0000 1100 0100 0101 in binary)
  30.  
  31. Set date.
  32.  
  33. FUNCTION t_setdate( date : Integer ) : Integer ;
  34.   GEMDOS( $2b ) ;
  35.  
  36. This  call  is  used  to set the date, in the same format given for t_getdate,
  37. above.  It returns 0, if the date was  valid,  or  a  negative  error  number,
  38. otherwise.
  39.  
  40. Get time.
  41.  
  42. Of  course,  the  date  alone is not enough.  You also need to set and get the
  43. current system time.  This time value is only accurate to an  even  number  of
  44. seconds,  however,  since  there  are  only 5 bits allocated for returning the
  45. current second.
  46.  
  47. FUNCTION t_gettime : Integer ;
  48.  
  49. Use this call to find our the  current  system  time  since  midnight  on  the
  50. current day.  The time is returned as an integer in the following format:
  51.  
  52.  bits   contents
  53. -----   --------
  54.  0- 4   number of two-seconds (0-29)
  55.  5-10   number of minutes (0-59)
  56. 11-15   number of hours (0-23)
  57.  
  58. Notice that the seconds returned is the number of two-second intervals, so you
  59. have  to  multiply  by two to get the number of seconds.  This also means that
  60. the clock is only accurate to an even number of seconds.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Time and Date                                                           Page 2
  71.  
  72. Set time.
  73.  
  74. FUNCTION t_settime( time : integer ) : integer ;
  75.   GEMDOS( $2d ) ;
  76.  
  77. This call sets the time using the same  format  as  the  t_gettime  call.   It
  78. returns 0, if the time was valid, and a negative error number, otherwise.
  79.  
  80.  
  81. The calls described above are the "GEMDOS" calls for date and time.  There are
  82. also  underlying  XBIOS  calls  to  perform  the same functions.  As usual, we
  83. advise that you use the GEMDOS  calls  whenever  possible  (unless  they  have
  84. bugs!).
  85.  
  86. Set the system date and time.
  87.  
  88. PROCEDURE settime( date, time : integer ) ;
  89.   XBIOS( 22 ) ;
  90.  
  91. This  call  sets  the date and time in the intelligent keyboard.  The date and
  92. time are the same format as the GEMDOS set date and set time  calls  described
  93. above.  You should normally use the GEMDOS calls, not this call.
  94.  
  95. Get the system date and time.
  96.  
  97. FUNCTION gettime : Long_Integer ;
  98.   XBIOS( 23 ) ;
  99.  
  100. This  call  returns the current date in the high word of the result parameter,
  101. and the current time in the low word, both in standard GEMDOS format.
  102. sssssssssssss